//
//  UIColor+Mycolor.m
//  Inspiration
//
//  Created by Mac on 15/10/15.
//  Copyright © 2015年 riverlj. All rights reserved.
//

#import "UIColor+Mycolor.h"

@implementation UIColor (Mycolor)
/**
 *  生成UIColor 参数是float数值0.0~256.0
 *
 *  @param red   红色
 *  @param green 绿色
 *  @param blue  蓝色
 *  @param alpha 透明度
 *
 *  @return UIColor
 */
+ (UIColor *)colorWithR:(CGFloat) red G:(CGFloat)green B:(CGFloat)blue A:(CGFloat)alpha
{
    return [UIColor colorWithRed:red/256 green:green/256 blue:blue/256 alpha:1.0];

}

//  颜色转换为背景图片
+ (UIImage *)imageWithColor:(UIColor *)color {
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return image;
}


@end
